#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
using namespace std;
  struct ListNode {
      int val;
      ListNode *next;
      ListNode() : val(0), next(nullptr) {}
      ListNode(int x) : val(x), next(nullptr) {}
      ListNode(int x, ListNode *next) : val(x), next(next) {}
  };
 
class Solution {
public:
    bool isPalindrome(ListNode* head)
    {
        vector<int> v;
        ListNode* cur = head;
        while (cur)
        {
            v.push_back(cur->val);
            cur = cur->next;
        }
        int left = 0, right = v.size() - 1;
        while (left < right)
        {
            if (v[left] != v[right])
            {
                return false;
            }
            ++left;
            --right;
        }
        return true;
    }
};